package com.gaoyang;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class SimpleSync {

    // 可以容纳10个线程的执行器.
    final static ExecutorService exec = Executors.newFixedThreadPool(10);

    public static void main(String[] args)
    {
        System.out.println("Start first SYNC program.");

        //放进10个线程并行跑
        for (int i = 0; i < 10; i++)
        {
            SimpleRunner runner = new SimpleRunner();
            runner.setRunIndex(i);
            exec.submit(runner);
        }

        exec.shutdown();//关闭执行器

        System.out.println("Finish first SYNC program.");
    }
}
